<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@page import ="rai.dto.*" %>
<%@page import ="rai.dao.*" %>
<%@page import = "java.util.*" %>
<script type="text/javascript">
	function getForm(namespace, name) {
		return document.forms[namespace + name];
	}
	function access_to_search_form(namespace, name){
		var frm = getForm(namespace , name);
		frm.txtAction.value = "access_to_search_form";
		frm.submit();
	}
	function back_to_login(namespace, name) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = "back_to_login_form";
		frm.submit();
	}
	function back_to_emp_info_form(namespace, name) {
        var frm = getForm(namespace, name);
        frm.txtAction.value = "back_to_empInfo_form_2";
        frm.submit();
    }
	function updateProfile(namespace, name) {
        var frm = getForm(namespace, name);
        if (frm.txtNewPassword.value != frm.txtConfirmPassword.value) {
            alert("New Password must match");
        } else {
        	frm.txtAction.value = "do_edit_profile";
        	frm.submit();
        }
    }
	
</script>

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Personal Information Tracking System</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href='<%=request.getContextPath()+"css/style.css"%>' rel="stylesheet" type="text/css" media="screen" /></head>

<body>
<form name="<portlet:namespace/>editProfileForm" action="<portlet:actionURL/>" method="POST">
	<input type="hidden" name="txtAction" />
	
	
<table align="center">
	<tr class="title">
			<td>		
					<h1><font color="blue">Personal information tracking system</font></h1>
					<p>Exploit the value of data</p>
					<hr />
			</td>
	</tr>
	<%Integer myid=(Integer) session.getAttribute("ID");
	  String role = (String) session.getAttribute("role");%>
	  
	 <tr>
		<td colspan="2" align="left"> Welcome, <font color="orange"/><b>[${sessionScope.role}]${sessionScope.name}</b></font>
		| <a href="#" onclick="back_to_emp_info_form('<portlet:namespace/>','editProfileForm')">Home</a> 
		<%if(role.equals("PM")){ %>
			| <a href="#" onclick="access_to_search_form('<portlet:namespace/>','editProfileForm')">Search</a>
			
		<%} %>
		| <a href="#" onclick="back_to_login('<portlet:namespace/>','editProfileForm')">Logout</a>
			
	   </td>
	</tr>
	<tr>			
		<td>
			<table border="1" style="width: 480px">
				<tr>
					<td><h2 class="title">Edit Profile </h2></td>
				</tr>
				<tr>
					<td>
						<table border="1" width="100%">
							<tr>
								<td>UserName</td>
								<td>${sessionScope.name}</td>
							</tr>
							<tr>
								<td style="width: 190px">Old Password</td>
								<td><input name="txtOldPassword" type="password" style="width: 186px"/></td>
							</tr>
							<tr>
								<td>New Password</td>
								<td><input name="txtNewPassword" type="password" style="width: 186px"/></td>
							</tr>
							<tr>
								<td>Confirm New Password</td>
								<td><input name="txtConfirmPassword" type="password" style="width: 186px"/></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<input type="button" name="btnUpdate" value="Update" 
							onclick="updateProfile('<portlet:namespace/>','editProfileForm')" />
						<input type="button" name="btnCancel" value="Cancel" 
							onclick="back_to_emp_info_form('<portlet:namespace/>','editProfileForm')" />
						<p style=""><b><font color="red">${sessionScope.succMess}</font></b></p>
					</td>
					
				</tr>
			</table>			
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<div style="clear: both;">&nbsp;</div>

			<div id="footer"><p>Development by HCMUT-Group3.</p>
			</div>
		</td>
	</tr>
</table>
</form>
</body>